#include <cstring>
#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n;
const int MAXN = 1e6 + 10;

int a[MAXN];
int temp[MAXN];
long long sum[MAXN];

long long mood = 0; //心情
long long mleft, mright;

int ans = 0;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i]; //前缀和数组
    }
    //设置K初始值为2, 计算left和right
    int index = 1;

    for (int k = 2; k <= n; k++) //先筛选符合条件的元素
    {
        mright = sum[n] - sum[k - 1];
        mleft = sum[k - 1] - sum[0];
        if (mright < 0)
            continue;
        if (mright + mleft < 0)
            continue;
        temp[index++] = k;
    }

    for (int i = 1; i < index; i++)
    {
        bool flag = true;
        int k = temp[i];
        for (int j = k; j <= n; j++)
        {
            mood += a[j];
            if (mood < 0)
            {
                flag = false;
                break;
            }
        }
        for (int j = 1; j <= k - 1 && flag; j++)
        {
            mood += a[j];
            if (mood < 0)
            {
                flag = false;
                break;
            }
        }
        mood = 0;
        if (flag)
            ans++;
    }
    cout << ans << endl;
    system("pause");
    return 0;
}